inherited sprSubTariffs: TsprSubTariffs
  ActiveControl = GroupBox1
  Caption = #1057#1087#1088#1072#1074#1086#1095#1085#1080#1082' '#1090#1072#1088#1080#1092#1086#1074', '#1074#1082#1083#1102#1095#1077#1085#1085#1099#1093' '#1074' '#1090#1072#1088#1080#1092' '#1087#1086' '#1089#1086#1076#1077#1088#1078#1072#1085#1080#1102' '#1078#1080#1083#1100#1103
  PixelsPerInch = 96
  TextHeight = 13
  inherited ToolBar1: TToolBar
    Height = 0
    TabOrder = 3
    Visible = False
  end
  inherited Panel2: TPanel
    Top = 0
    Width = 521
    Height = 554
    TabOrder = 1
    inherited PageControl1: TPageControl
      Width = 521
      Height = 554
      ActivePage = tsForm
      Style = tsFlatButtons
      inherited tsTab: TTabSheet
        inherited GroupBox3: TGroupBox
          Width = 513
          Height = 523
          inherited dbgRefer: TDBGridEh
            Width = 509
            Height = 506
            OnDblClick = dbgReferDblClick
            Columns = <
              item
                EditButtons = <>
                FieldName = 'ADDRESS'
                Footers = <>
              end
              item
                EditButtons = <>
                FieldName = 'BDATE'
                Footers = <>
              end
              item
                EditButtons = <>
                FieldName = 'TARIFF'
                Footers = <>
              end
              item
                EditButtons = <>
                FieldName = 'DOG_TARIFF_ID'
                Footers = <>
                Visible = False
              end
              item
                EditButtons = <>
                FieldName = 'SUB_TARIFF'
                Footers = <>
              end>
          end
        end
      end
      inherited tsForm: TTabSheet
        inherited GroupBox2: TGroupBox
          Top = 0
          Width = 513
          Height = 523
          Align = alClient
          inherited pnlButtons: TPanel
            Top = 490
            Width = 509
            inherited SpeedButton1: TSpeedButton
              Left = 310
            end
            inherited SpeedButton2: TSpeedButton
              Left = 412
            end
          end
          object Panel1: TPanel
            Left = 2
            Top = 15
            Width = 509
            Height = 95
            Align = alTop
            BevelOuter = bvNone
            TabOrder = 1
            object Label4: TLabel
              Left = 16
              Top = 29
              Width = 88
              Height = 13
              Alignment = taRightJustify
              AutoSize = False
              Caption = #1044#1072#1090#1072' '#1085#1072#1095#1072#1083#1072
              Font.Charset = DEFAULT_CHARSET
              Font.Color = clWindowText
              Font.Height = -11
              Font.Name = 'MS Sans Serif'
              Font.Style = []
              ParentFont = False
            end
            object Label5: TLabel
              Left = 16
              Top = 53
              Width = 88
              Height = 13
              Alignment = taRightJustify
              AutoSize = False
              Caption = #1054#1089#1085#1086#1074#1085#1086#1081' '#1090#1072#1088#1080#1092
              Font.Charset = DEFAULT_CHARSET
              Font.Color = clWindowText
              Font.Height = -11
              Font.Name = 'MS Sans Serif'
              Font.Style = []
              ParentFont = False
            end
            object Label6: TLabel
              Left = 16
              Top = 77
              Width = 88
              Height = 13
              Alignment = taRightJustify
              AutoSize = False
              Caption = #1057#1091#1073#1090#1072#1088#1080#1092#1099
              Font.Charset = DEFAULT_CHARSET
              Font.Color = clWindowText
              Font.Height = -11
              Font.Name = 'MS Sans Serif'
              Font.Style = []
              ParentFont = False
            end
            object Label8: TLabel
              Left = 16
              Top = 5
              Width = 88
              Height = 13
              Alignment = taRightJustify
              AutoSize = False
              Caption = #1040#1076#1088#1077#1089
              Font.Charset = DEFAULT_CHARSET
              Font.Color = clWindowText
              Font.Height = -11
              Font.Name = 'MS Sans Serif'
              Font.Style = []
              ParentFont = False
            end
            object dbeTariff: TDBEditEh
              Left = 112
              Top = 50
              Width = 89
              Height = 19
              AlwaysShowBorder = True
              Color = clInactiveCaptionText
              DataField = 'TARIFF'
              DataSource = dscRefer
              EditButtons = <>
              Flat = True
              ReadOnly = True
              TabOrder = 0
              Visible = True
            end
            object dbtTariffBDate: TDBDateTimeEditEh
              Left = 112
              Top = 26
              Width = 89
              Height = 19
              AlwaysShowBorder = True
              Color = clInactiveCaptionText
              DataField = 'BDATE'
              DataSource = dscRefer
              EditButtons = <>
              Flat = True
              Kind = dtkDateEh
              ReadOnly = True
              TabOrder = 1
              Visible = True
              OnExit = dbtBdateExit
              OnKeyUp = lcbTownKeyUp
            end
            object dbeAddress: TDBEditEh
              Left = 112
              Top = 2
              Width = 377
              Height = 19
              AlwaysShowBorder = True
              Color = clInactiveCaptionText
              DataField = 'ADDRESS'
              DataSource = dscRefer
              EditButtons = <>
              Flat = True
              ReadOnly = True
              TabOrder = 2
              Visible = True
            end
          end
          object dbgSubTariffs: TDBGridEh
            Left = 2
            Top = 134
            Width = 509
            Height = 356
            Align = alClient
            ColumnDefValues.Title.TitleButton = True
            DataGrouping.GroupLevels = <>
            DataSource = dscSubTariffs
            Flat = True
            FooterColor = clWindow
            FooterFont.Charset = DEFAULT_CHARSET
            FooterFont.Color = clWindowText
            FooterFont.Height = -11
            FooterFont.Name = 'MS Sans Serif'
            FooterFont.Style = []
            FooterRowCount = 1
            IndicatorTitle.TitleButton = True
            OddRowColor = clWindow
            Options = [dgEditing, dgTitles, dgColLines, dgRowLines, dgTabs, dgAlwaysShowSelection, dgConfirmDelete]
            OptionsEh = [dghFixed3D, dghHighlightFocus, dghClearSelection, dghAutoSortMarking, dghMultiSortMarking, dghDblClickOptimizeColWidth, dghDialogFind, dghColumnResize]
            RowDetailPanel.Color = clBtnFace
            SortLocal = True
            SumList.Active = True
            TabOrder = 2
            TitleFont.Charset = DEFAULT_CHARSET
            TitleFont.Color = clWindowText
            TitleFont.Height = -11
            TitleFont.Name = 'MS Sans Serif'
            TitleFont.Style = []
            UseMultiTitle = True
            VTitleMargin = 5
            OnDblClick = aEditExecute
            OnDrawFooterCell = dbgSubTariffsDrawFooterCell
            OnSortMarkingChanged = dbgReferSortMarkingChanged
            Columns = <
              item
                DropDownBox.ListSource = dscSubServices2
                DropDownBox.Options = [dlgColumnResizeEh]
                DropDownSizing = True
                EditButtons = <>
                FieldName = 'SUB_SERVICE'
                Footer.Font.Charset = DEFAULT_CHARSET
                Footer.Font.Color = clWindowText
                Footer.Font.Height = -11
                Footer.Font.Name = 'MS Sans Serif'
                Footer.Font.Style = [fsBold]
                Footer.Value = #1048#1090#1086#1075#1086':'
                Footer.ValueType = fvtStaticText
                Footers = <>
                Width = 197
              end
              item
                EditButtons = <>
                FieldName = 'TARIFF'
                Footer.FieldName = 'TARIFF'
                Footer.Font.Charset = DEFAULT_CHARSET
                Footer.Font.Color = clWindowText
                Footer.Font.Height = -11
                Footer.Font.Name = 'MS Sans Serif'
                Footer.Font.Style = [fsBold]
                Footer.ValueType = fvtSum
                Footers = <>
                Width = 74
              end
              item
                EditButtons = <>
                FieldName = 'NOTE'
                Footers = <>
              end
              item
                EditButtons = <>
                FieldName = 'ID'
                Footers = <>
                Visible = False
              end
              item
                EditButtons = <>
                FieldName = 'CREATEDATE'
                Footers = <>
                Visible = False
              end
              item
                EditButtons = <>
                FieldName = 'CREATEUSERID'
                Footers = <>
                Visible = False
              end
              item
                EditButtons = <>
                FieldName = 'MODIFYDATE'
                Footers = <>
                Visible = False
              end
              item
                EditButtons = <>
                FieldName = 'MODIFYUSERID'
                Footers = <>
                Visible = False
              end>
            object RowDetailData: TRowDetailPanelControlEh
            end
          end
          object tbTariff: TToolBar
            Left = 2
            Top = 110
            Width = 509
            Height = 24
            AutoSize = True
            Flat = True
            Images = MAIN.ImageList
            TabOrder = 3
            object ToolButton12: TToolButton
              Left = 0
              Top = 0
              Action = aInsert
            end
            object ToolButton13: TToolButton
              Left = 23
              Top = 0
              Action = aEdit
            end
            object ToolButton14: TToolButton
              Left = 46
              Top = 0
              Action = aDelete
            end
          end
        end
      end
    end
  end
  inherited GroupBox1: TGroupBox
    Left = 521
    Top = 0
    Width = 271
    Height = 554
    Align = alRight
    TabOrder = 0
    object Label1: TLabel
      Left = 9
      Top = 27
      Width = 54
      Height = 13
      Alignment = taRightJustify
      Caption = #1053#1072#1089'. '#1087#1091#1085#1082#1090
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
    end
    object Label2: TLabel
      Left = 31
      Top = 51
      Width = 32
      Height = 13
      Alignment = taRightJustify
      Caption = #1059#1083#1080#1094#1072
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
    end
    object Label3: TLabel
      Left = 40
      Top = 75
      Width = 23
      Height = 13
      Alignment = taRightJustify
      Caption = #1044#1086#1084
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
    end
    object Label7: TLabel
      Left = 28
      Top = 99
      Width = 35
      Height = 13
      Alignment = taRightJustify
      Caption = #1057' '#1076#1072#1090#1099
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
    end
    object Label9: TLabel
      Left = 8
      Top = 168
      Width = 236
      Height = 65
      Caption = 
        #1042#1099#1074#1086#1076#1103#1090#1089#1103' '#1090#1086#1083#1100#1082#1086' '#1080#1085#1076#1080#1074#1080#1076#1091#1072#1083#1100#1085#1099#1077' '#1090#1072#1088#1080#1092#1099' '#1085#1072' '#1089#1086#1076#1077#1088#1078#1072#1085#1080#1077' '#1078#1080#1083#1100#1103' '#1087#1086' '#1076#1086 +
        #1075#1086#1074#1086#1088#1072#1084' '#1085#1072' '#1091#1089#1083#1091#1075#1080', '#1080#1084#1077#1102#1097#1080#1084' '#1087#1088#1080#1079#1085#1072#1082' "'#1089#1086#1076#1077#1088#1078#1072#1085#1080#1077' '#1078#1080#1083#1100#1103'"(SVC_SODERJ' +
        '), '#1080' '#1085#1072#1095#1080#1085#1072#1102#1097#1080#1077#1103' '#1087#1086#1079#1078#1077' '#1091#1082#1072#1079#1072#1085#1085#1086#1081' '#1074' '#1092#1080#1083#1100#1090#1088#1077' '#1076#1072#1090#1099
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
      WordWrap = True
    end
    object lcbTown: TDBLookupComboboxEh
      Left = 72
      Top = 24
      Width = 187
      Height = 19
      AlwaysShowBorder = True
      DropDownBox.Sizable = True
      DropDownBox.SpecRow.CellsText = ' ---'
      DropDownBox.SpecRow.Value = -1
      DropDownBox.SpecRow.Visible = True
      EditButtons = <>
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      Flat = True
      KeyField = 'CODE'
      ListField = 'NAME'
      ListSource = dscTown
      ParentFont = False
      TabOrder = 0
      Visible = True
      OnChange = lcbTownChange
      OnKeyUp = lcbTownKeyUp
    end
    object lcbStreet: TDBLookupComboboxEh
      Left = 72
      Top = 48
      Width = 187
      Height = 19
      AlwaysShowBorder = True
      DropDownBox.Sizable = True
      DropDownBox.SpecRow.CellsText = ' ---'
      DropDownBox.SpecRow.Value = -1
      DropDownBox.SpecRow.Visible = True
      EditButtons = <>
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      Flat = True
      KeyField = 'CODE'
      ListField = 'STREET'
      ListSource = dscStreet
      ParentFont = False
      TabOrder = 1
      Visible = True
      OnChange = lcbStreetChange
      OnKeyUp = lcbTownKeyUp
    end
    object lcbHouse: TDBLookupComboboxEh
      Left = 72
      Top = 72
      Width = 187
      Height = 19
      AlwaysShowBorder = True
      DropDownBox.Sizable = True
      DropDownBox.SpecRow.CellsText = ' ---'
      DropDownBox.SpecRow.Value = -1
      DropDownBox.SpecRow.Visible = True
      EditButtons = <>
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      Flat = True
      KeyField = 'ID'
      ListField = 'HOUSE_NUM'
      ListSource = dscHouse
      ParentFont = False
      TabOrder = 2
      Visible = True
      OnKeyUp = lcbTownKeyUp
    end
    object BitBtn1: TBitBtn
      Left = 72
      Top = 126
      Width = 89
      Height = 25
      Action = aRefresh
      Caption = #1054#1073#1085#1086#1074#1080#1090#1100
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
      TabOrder = 4
      Glyph.Data = {
        36040000424D3604000000000000360000002800000010000000100000000100
        2000000000000004000000000000000000000000000000000000FF00FF00FFB8
        6B00FFA94A00FFA94A00FFA94A00FFA94A00FFA94A00FFA94A00FFA94A00FFA9
        4A00FFA94A00FFA94A00FFA94A00FF941F00FF00FF00FF00FF00FFAC5200FF96
        18003C915E00FFB65200FFB65200489A6A004297660042976600489A6A00FFB2
        4A00FFB24A00FFB24A00FFB24A00FF921000FFAC5200FF00FF00FF890800FFB6
        5A002B87500099CBAD0049A06E0095DAB70095DAB70095D8B50095D7B400489A
        6A00CCF2DE00FFB65A00F7B65200FFAE4A00FF890800FF00FF00FF8D0800FFB6
        5A002B87500099F0C50093DCB70040D48A0040D1880093E2B90093E2B90095D7
        B4002B875000F7AE5200F7AE4A00F7AE4A00FF8D0800FF00FF00FF8D0800FFB6
        5A002B87500099F0C5003FD4880040D0870097D8B6002B8750002B8750002B87
        500089BC9E002B875000F7AE4A00F7AE4A00FF8D0800FF00FF00FF8D0800F7AE
        52002B875000B0F3D30098EEC30099F0C5002B875000F7AA4A00F7AA4A00F7AA
        4A00429A68002B875000F7A64200F7A64200FF8D0800FF00FF00FF8D0800F7AA
        4A002B8750002B8750002B8750002B8750002B8750002B875000F7A24200F7A2
        4200F7A2420044986700EFA23900EF9E3900FF8D0800FF00FF00FF8D0800F7AA
        3900EFA23900EFA23900EF9E3900EF9E3900EF9E3900EF9E3900EF9E3900EF9A
        3900EF9A3900EF9A3100EF9A3100F7A62100FF890800FF00FF00FF8D0800FFC7
        3900FFC7310044986700F7AA3100EFA23100EF9A31002B8750002B8750002B87
        50002B8750002B8750002B875000FFBE1800FF890800FF00FF00FF8D0800FFCB
        4A00FFD34A002B875000429A6800FFCF4200FFCF4200FFCF39002B87500098EE
        C30095E5BD0094E0B9002B875000FFC32900FF890800FF00FF00FF890800FFCF
        5A00FFD763002B87500089BC9E002B8750002B8750002B87500097D8B60040D0
        87003FD4880095E5BD002B875000FFC73900FF890800FF00FF00FF890800FFD3
        6B00FFDF7300FFDF73002B875000B7EED30093E2B90093E2B90040D1880040D4
        8A0093DCB700BBF2D6002B875000FFC74A00FF890800FF00FF00FF890800FFCF
        7300FFE38C00FFE38C00CCF2DE00439D6A00BBF2D600B7EED300BBF2D600BBF2
        D60049A06E0099CBAD002B875000FFC75200FF890800FF00FF00FFAC5200FF9E
        2100FFCB7300FFD37B00FFD37B00FFD37B00489A6A004297660042976600489A
        6A00FFD37300FFD36B003C915E00FFAA3100FFAC5200FF00FF00FF00FF00FFB8
        6B00FFA94A00FFA94A00FFA94A00FFA94A00FFA94A00FFA94A00FFA94A00FFA9
        4A00FFA94A00FFA94A00FFA94A00FF941F00FF00FF00FF00FF00FF00FF00FF00
        FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00}
    end
    object dbtBdate: TDBDateTimeEditEh
      Left = 72
      Top = 96
      Width = 89
      Height = 19
      AlwaysShowBorder = True
      EditButtons = <>
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      Flat = True
      Kind = dtkDateEh
      ParentFont = False
      TabOrder = 3
      Visible = True
      OnExit = dbtBdateExit
      OnKeyUp = lcbTownKeyUp
    end
  end
  inherited shblActionList: TActionList
    inherited aRefresh: TAction
      ShortCut = 116
    end
  end
  inherited dsRefer: TpFIBDataSet
    UpdateSQL.Strings = (
      ''
      '    ')
    InsertSQL.Strings = (
      '')
    RefreshSQL.Strings = (
      'select'
      '  v.address,'
      '  dt.bdate,'
      '  dt.tariff,'
      '  dt.id as dog_tariff_id,'
      '  sum(st.tariff) as sub_tariff'
      'from dogovor_tariffs dt'
      'join dogovors d on d.id = dt.dogovor_id'
      '  and dt.seq = 1'
      'join v_abons v on v.id = d.abonent_id'
      'join services s on s.id = d.service_id'
      '  and exists(select 1 from vw_straits vw'
      '                     where vw.service_id in (s.id, s.group_id)'
      '                       and vw.code = '#39'SVC_SODERJ'#39')'
      
        'left join sub_dogovor_tariffs st on dt.id = st.dogovors_tariff_i' +
        'd'
      '  and st.is_deleted = 0'
      'where coalesce(:ptown_id, -1) in (-1, v.town_id)'
      '  and coalesce(:pstreet_id, -1) in (-1, v.street_id)'
      '  and coalesce(:pbuilding_id, -1) in (-1, v.building_id)'
      '  and dt.bdate >= :pdate'
      '  and dt.id = :OLD_DOG_TARIFF_ID'
      'group by 1,2,3,4')
    SelectSQL.Strings = (
      'select'
      '  v.address,'
      '  dt.bdate,'
      '  dt.tariff,'
      '  dt.id as dog_tariff_id,'
      '  sum(st.tariff) as sub_tariff'
      'from dogovor_tariffs dt'
      'join dogovors d on d.id = dt.dogovor_id'
      '  and dt.seq = 1'
      'join v_abons v on v.id = d.abonent_id'
      'join services s on s.id = d.service_id'
      '  and exists(select 1 from vw_straits vw'
      '                     where vw.service_id in (s.id, s.group_id)'
      '                       and vw.code = '#39'SVC_SODERJ'#39')'
      
        'left join sub_dogovor_tariffs st on dt.id = st.dogovors_tariff_i' +
        'd'
      '  and st.is_deleted = 0'
      'where coalesce(:ptown_id, -1) in (-1, v.town_id)'
      '  and coalesce(:pstreet_id, -1) in (-1, v.street_id)'
      '  and coalesce(:pbuilding_id, -1) in (-1, v.building_id)'
      '  and dt.bdate >= :pdate'
      'group by 1,2,3,4')
    BeforeOpen = dsReferBeforeOpen
    object dsReferADDRESS: TFIBStringField
      DisplayLabel = #1040#1076#1088#1077#1089
      DisplayWidth = 25
      FieldName = 'ADDRESS'
      Size = 258
      EmptyStrToNull = True
    end
    object dsReferBDATE: TFIBDateField
      DisplayLabel = #1044#1072#1090#1072' '#1085#1072#1095#1072#1083#1072' '#1076#1077#1081#1089#1090#1074#1080#1103
      DisplayWidth = 12
      FieldName = 'BDATE'
    end
    object dsReferTARIFF: TFIBBCDField
      DisplayLabel = #1054#1089#1085#1086#1074#1085#1086#1081' '#1090#1072#1088#1080#1092
      FieldName = 'TARIFF'
      Size = 2
      RoundByScale = True
    end
    object dsReferDOG_TARIFF_ID: TFIBIntegerField
      FieldName = 'DOG_TARIFF_ID'
    end
    object dsReferSUB_TARIFF: TFIBBCDField
      DisplayLabel = #1057#1091#1084#1084#1072' '#1089#1091#1073#1090#1072#1088#1080#1092#1086#1074
      DisplayWidth = 16
      FieldName = 'SUB_TARIFF'
      Size = 2
      RoundByScale = True
    end
  end
  inherited Timer1: TTimer
    Left = 576
    Top = 273
  end
  inherited trLists: TpFIBTransaction
    Top = 261
  end
  inherited PropStorage: TPropStorageEh
    Section = 'TsprSubTariffs'
    StoredProps.Strings = (
      '<P>.Height'
      '<P>.Left'
      '<P>.Top'
      '<P>.Width'
      '<P>.WindowState'
      
        'Panel2.PageControl1.tsForm.GroupBox2.dbgSubTariffs.<P>.Columns.C' +
        'olumnsIndex'
      
        'Panel2.PageControl1.tsForm.GroupBox2.dbgSubTariffs.<P>.Columns.<' +
        'ForAllItems>.Width'
      
        'Panel2.PageControl1.tsTab.GroupBox3.dbgRefer.<P>.Columns.Columns' +
        'Index'
      
        'Panel2.PageControl1.tsTab.GroupBox3.dbgRefer.<P>.Columns.<ForAll' +
        'Items>.Width')
    Left = 160
  end
  object dsTown: TpFIBDataSet
    SelectSQL.Strings = (
      'SELECT'
      '    CODE,'
      '    NAME'
      'FROM PAS_RTOWN r'
      'where local = 1'
      '  and exists(select 1 from rstreets s where s.town_id = r.code)'
      'order by 2')
    Transaction = trLists
    Database = MAINDM.pMainDatabase
    Left = 312
    Top = 29
    oRefreshAfterPost = False
    oRefreshAfterDelete = True
    oRefreshDeletedRecord = True
    oFetchAll = True
    object dsTownCODE: TFIBIntegerField
      FieldName = 'CODE'
    end
    object dsTownNAME: TFIBStringField
      FieldName = 'NAME'
      Size = 60
      EmptyStrToNull = True
    end
  end
  object dscTown: TDataSource
    DataSet = dsTown
    Left = 344
    Top = 29
  end
  object dsStreet: TpFIBDataSet
    SelectSQL.Strings = (
      'SELECT'
      '    STREET,'
      '    CODE'
      'FROM RSTREETS s'
      'where TOWN_ID = :CODE'
      
        '  and exists(select 1 from buildings b where b.street_id = s.cod' +
        'e)'
      'order by 1')
    BeforeOpen = dsStreetBeforeOpen
    Transaction = trLists
    Database = MAINDM.pMainDatabase
    Left = 312
    Top = 61
    WaitEndMasterScroll = True
    dcForceOpen = True
    oRefreshAfterPost = False
    oRefreshAfterDelete = True
    oRefreshDeletedRecord = True
    oFetchAll = True
    object dsStreetSTREET: TFIBStringField
      FieldName = 'STREET'
      Size = 120
      EmptyStrToNull = True
    end
    object dsStreetCODE: TFIBIntegerField
      FieldName = 'CODE'
    end
  end
  object dscStreet: TDataSource
    DataSet = dsStreet
    Left = 344
    Top = 61
  end
  object dsHouse: TpFIBDataSet
    SelectSQL.Strings = (
      'SELECT'
      '    ID,'
      '    HOUSE||coalesce('#39' '#1082'.'#39'||CORPS, '#39#39') as house_num'
      'FROM BUILDINGS b'
      'where STREET_ID = :CODE'
      '  and exists(select 1 from abonents a'
      '        join dogovors d on d.abonent_id = a.id'
      '        join services s on s.id = d.service_id'
      '        where a.building_id = b.id'
      '          and a.client_id = -1'
      '          and d.gen_tariff = 0'
      '          and d.is_active = 1'
      '          and exists(select 1 from vw_straits vw'
      '                     where vw.service_id in (s.id, s.group_id)'
      '                       and vw.code = '#39'SVC_SODERJ'#39'))')
    BeforeOpen = dsHouseBeforeOpen
    Transaction = trLists
    Database = MAINDM.pMainDatabase
    Left = 312
    Top = 93
    WaitEndMasterScroll = True
    dcForceOpen = True
    oRefreshAfterPost = False
    oRefreshAfterDelete = True
    oRefreshDeletedRecord = True
    oFetchAll = True
    object dsHouseID: TFIBIntegerField
      FieldName = 'ID'
    end
    object dsHouseHOUSE_NUM: TFIBStringField
      FieldName = 'HOUSE_NUM'
      Size = 22
      EmptyStrToNull = True
    end
  end
  object dscHouse: TDataSource
    DataSet = dsHouse
    Left = 344
    Top = 93
  end
  object dsSubServices: TpFIBDataSet
    SelectSQL.Strings = (
      'select'
      '    id,'
      '    shortname'
      'from'
      '    sub_services ss'
      'order by 2')
    Transaction = trRefer
    Database = MAINDM.pMainDatabase
    Left = 312
    Top = 157
    oRefreshAfterPost = False
    oRefreshAfterDelete = True
    oRefreshDeletedRecord = True
    oFetchAll = True
    object dsSubServicesID: TFIBIntegerField
      FieldName = 'ID'
    end
    object dsSubServicesSHORTNAME: TFIBStringField
      FieldName = 'SHORTNAME'
      Size = 30
      EmptyStrToNull = True
    end
  end
  object dscSubServices: TDataSource
    DataSet = dsSubServices
    Left = 344
    Top = 157
  end
  object dsSubTariffs: TpFIBDataSet
    UpdateSQL.Strings = (
      'UPDATE SUB_DOGOVOR_TARIFFS'
      'SET '
      '    TARIFF = :TARIFF,'
      '    NOTE = :NOTE'
      'WHERE'
      '    ID = :OLD_ID'
      '    ')
    DeleteSQL.Strings = (
      'UPDATE SUB_DOGOVOR_TARIFFS'
      'SET '
      '    IS_DELETED = 1'
      'WHERE'
      '    ID = :OLD_ID')
    InsertSQL.Strings = (
      'INSERT INTO SUB_DOGOVOR_TARIFFS('
      '    SUB_SERVICE_ID,'
      '    DOGOVORS_TARIFF_ID,'
      '    TARIFF,'
      '    NOTE,'
      '    CREATEDATE,'
      '    CREATEUSERID,'
      '    MODIFYDATE,'
      '    MODIFYUSERID'
      ')'
      'VALUES('
      '    :SUB_SERVICE_ID,'
      '    :DOGOVORS_TARIFF_ID,'
      '    :TARIFF,'
      '    :NOTE,'
      '    :CREATEDATE,'
      '    :CREATEUSERID,'
      '    :MODIFYDATE,'
      '    :MODIFYUSERID'
      ')'
      'returning ID')
    RefreshSQL.Strings = (
      'SELECT'
      '    ID,'
      '    SUB_SERVICE_ID,'
      
        '    (select name from sub_services s where t.SUB_SERVICE_ID = s.' +
        'id) as SUB_SERVICE,'
      '    TARIFF,'
      '    NOTE,'
      '    CREATEDATE,'
      '    CREATEUSERID,'
      '    MODIFYDATE,'
      '    MODIFYUSERID'
      'FROM'
      '    SUB_DOGOVOR_TARIFFS t'
      'where IS_DELETED = 0'
      '  and DOGOVORS_TARIFF_ID = :pdog_tariff_id'
      '  and ID = :OLD_ID'
      '    ')
    SelectSQL.Strings = (
      'SELECT'
      '    ID,'
      '    SUB_SERVICE_ID,'
      
        '    (select name from sub_services s where t.SUB_SERVICE_ID = s.' +
        'id) as SUB_SERVICE,'
      '    TARIFF,'
      '    NOTE,'
      '    CREATEDATE,'
      '    CREATEUSERID,'
      '    MODIFYDATE,'
      '    MODIFYUSERID,'
      '    DOGOVORS_TARIFF_ID'
      'FROM'
      '    SUB_DOGOVOR_TARIFFS t'
      'where IS_DELETED = 0'
      '  and DOGOVORS_TARIFF_ID = :dog_tariff_id')
    AfterDelete = dsSubTariffsAfterOpen
    AfterInsert = dsSubTariffsAfterInsert
    AfterOpen = dsSubTariffsAfterOpen
    AfterPost = dsSubTariffsAfterOpen
    BeforeOpen = dsSubTariffsBeforeOpen
    BeforePost = dsSubTariffsBeforePost
    Transaction = trRefer
    Database = MAINDM.pMainDatabase
    Left = 120
    Top = 221
    oRefreshAfterPost = False
    oRefreshAfterDelete = True
    oRefreshDeletedRecord = True
    oFetchAll = True
    object dsSubTariffsID: TFIBIntegerField
      FieldName = 'ID'
    end
    object dsSubTariffsSUB_SERVICE_ID: TFIBIntegerField
      DisplayLabel = #1057#1091#1073#1091#1089#1083#1091#1075#1072
      DisplayWidth = 25
      FieldName = 'SUB_SERVICE_ID'
      LookupKeyFields = 'ID'
    end
    object dsSubTariffsTARIFF: TFIBBCDField
      DisplayLabel = #1057#1091#1073#1090#1072#1088#1080#1092
      FieldName = 'TARIFF'
      Size = 2
      RoundByScale = True
    end
    object dsSubTariffsNOTE: TFIBStringField
      DisplayLabel = #1055#1088#1080#1084#1077#1095#1072#1085#1080#1077
      DisplayWidth = 25
      FieldName = 'NOTE'
      Size = 255
      EmptyStrToNull = True
    end
    object dsSubTariffsCREATEDATE: TFIBDateField
      FieldName = 'CREATEDATE'
    end
    object dsSubTariffsCREATEUSERID: TFIBIntegerField
      FieldName = 'CREATEUSERID'
    end
    object dsSubTariffsMODIFYDATE: TFIBDateField
      FieldName = 'MODIFYDATE'
    end
    object dsSubTariffsMODIFYUSERID: TFIBIntegerField
      FieldName = 'MODIFYUSERID'
    end
    object dsSubTariffsDOGOVORS_TARIFF_ID: TFIBIntegerField
      FieldName = 'DOGOVORS_TARIFF_ID'
    end
    object dsSubTariffssub_service: TFIBStringField
      DisplayLabel = #1057#1091#1073#1091#1089#1083#1091#1075#1072
      DisplayWidth = 30
      FieldKind = fkLookup
      FieldName = 'SUB_SERVICE'
      LookupDataSet = dsSubServices
      LookupKeyFields = 'ID'
      LookupResultField = 'SHORTNAME'
      KeyFields = 'SUB_SERVICE_ID'
      Size = 120
      EmptyStrToNull = True
      Lookup = True
    end
  end
  object dscSubTariffs: TDataSource
    DataSet = dsSubTariffs
    OnDataChange = dscSubTariffsDataChange
    Left = 152
    Top = 221
  end
  object dsSubServices2: TpFIBDataSet
    SelectSQL.Strings = (
      'select'
      '    id,'
      '    shortname'
      'from'
      '    sub_services ss'
      'where not exists (select 1 from sub_dogovor_tariffs dt'
      '    where dt.sub_service_id = ss.id'
      '      and dt.is_deleted = 0'
      '      and dt.dogovors_tariff_id = :dog_tariff_id)'
      'order by 2')
    BeforeOpen = dsSubServicesBeforeOpen
    Transaction = trRefer
    Database = MAINDM.pMainDatabase
    Left = 312
    Top = 189
    oRefreshAfterPost = False
    oRefreshAfterDelete = True
    oRefreshDeletedRecord = True
    oFetchAll = True
    object FIBIntegerField1: TFIBIntegerField
      FieldName = 'ID'
    end
    object FIBStringField1: TFIBStringField
      FieldName = 'SHORTNAME'
      Size = 30
      EmptyStrToNull = True
    end
  end
  object dscSubServices2: TDataSource
    DataSet = dsSubServices2
    Left = 344
    Top = 189
  end
end
